package test.aat.ejinr.todb;

import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.UUID;

public class DuxuanPhone {
	public static void main(String[] args) {
		try {
			String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; // 加载JDBC驱动
			String dbURL = "jdbc:sqlserver://211.103.170.182:1433; DatabaseName=ETS_CDW"; // 连接服务器和数据库sample
			String userName = "etscdw"; // 默认用户名
			String userPwd = "cusTomer665588DateBasE#"; // 密码
			Class.forName(driverName);
			Connection con = DriverManager.getConnection(dbURL, userName, userPwd);
			String sql = "insert into client_phones(id,username,phone,department,intime) values(?,?,?,?,?)";
			PreparedStatement ps = con.prepareStatement(sql);
			//
			BufferedReader br = new BufferedReader(new FileReader("F:\\我的桌面\\work\\(清理)导出_地区_浙江_10400.txt"));
			String s = null;
			while ((s = br.readLine()) != null) {
				ps.setString(1, UUID.randomUUID().toString());
				ps.setString(2, "");
				ps.setString(3, s);
				ps.setString(4, "duxuan");
				ps.setDate(5, new Date(new java.util.Date().getTime()));
				ps.execute();
			}
			con.commit();
			con.close();
			//
			br.close();
		} catch (Exception e) {
		}
	}
}
